//
//  ShopChooseItemsViewController.m
//  GetPowerDBO
//
//  Created by 周博 on 2017/8/12.
//  Copyright © 2017年 BogoZhou. All rights reserved.
//

#import "ShopChooseItemsViewController.h"
#import "BorderHelper.h"

@interface ShopChooseItemsViewController ()

@end

@implementation ShopChooseItemsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self UISetting];
}

- (void)UISetting{
    self.view.backgroundColor = kClearColor;
    _buttonBack.backgroundColor = [kBlackColor colorWithAlphaComponent:0.3];
    [self setItems];
    UIButton *button ;
    if (_typeValue.integerValue == 101) {
        button = (UIButton *)[self.view viewWithTag:101];
    }else if (_typeValue.integerValue == 102){
        button = (UIButton *)[self.view viewWithTag:102];
    }else {
        button = (UIButton *)[self.view viewWithTag:103];
    }
    [self chooseShopButtonClick:button];
    [self setFuncItems];
}

- (void)setItems{
    [BorderHelper setBorderWithColor:ke6e6e6 view:_buttonAllShop];
    [BorderHelper setBorderWithColor:ke6e6e6 view:_buttonWifi];
    [BorderHelper setBorderWithColor:ke6e6e6 view:_buttonMima];
    if ([BGFunctionHelper isNULLOfString:_typeValue]) {
        _typeValue = @"101";
    }
}

- (void)setFuncItems{
    [BorderHelper setBorderWithColor:ke6e6e6 view:_buttonCancel];
    _buttonSure.backgroundColor = kGreenColor;
    
}

- (void)chooseButtonTypeWithButton:(UIButton *)button{
    button.layer.borderColor = [kGreenColor CGColor];
    button.layer.borderWidth = 0.5f;
    [button setTitleColor:kGreenColor forState:UIControlStateNormal];
    button.backgroundColor = [kGreenColor colorWithAlphaComponent:0.2];
}

#pragma mark - 点击事件

- (IBAction)backButtonClick:(UIButton *)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

//101 -> 全部店铺 102 -> WiFi店铺  103 -> 密码店铺
- (IBAction)chooseShopButtonClick:(UIButton *)sender {
    if (sender.tag == 101) {
        _typeValue = @"101";
    }else if (sender.tag == 102){
        _typeValue = @"102";
    }else {
        _typeValue = @"103";
    }
    [self setItems];
    [self chooseButtonTypeWithButton:sender];
}


//201 -> 取消 202 -> 确定
- (IBAction)cancelAndSureButtonClick:(UIButton *)sender {
    if (sender.tag == 201) {
        //cancel
        [self dismissViewControllerAnimated:YES completion:nil];
    }else{
        //sure
        [_delegate chooseItemsInShopVCWithNum:_typeValue];
        [self dismissViewControllerAnimated:YES completion:nil];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
